import QtQuick 2.0
import VPlay 2.0
import QtQuick.Controls 1.2
import "../common" as Common

import QtWebSockets 1.0

Common.LevelBase {
  levelName: "Controller"

  Common.MenuButton {
    id: go_button
    text: "启动!"
    width: 100
    height: 50
    color: "#c9ffff"
    anchors.left: parent.left
    anchors.verticalCenter: parent.verticalCenter
    anchors.verticalCenterOffset: -(height / 2)
    onClicked: {
      buttonPressed(18)
    }
  }
  Common.MenuButton {
    text: "停止!"
    width: 100
    height: 50
    color: "#c9c9e9"
    anchors.left: parent.left
    anchors.top: go_button.bottom
    //anchors.verticalCenter: parent.verticalCenter
    onClicked: {
      buttonPressed(19)
    }
  }

//  // name of the current level
//  Rectangle {
//    id: rectangle
//    color: "blue"
//    width: 100
//    height: 100
//    radius: 10

//    MouseArea {
//      anchors.fill: parent
//      onPressed: rectanglePressed()
//    }
//  }
  Grid {
    anchors.centerIn: parent
    //anchors.horizontalCenter: parent.horizontalCenter
    //y: dp(40)
    //width: Math.min(parent.width - dp(20), dp(450))
    columns: 3

    Repeater {
      model: [
        { text: "1", code: 1  }, { text: "2", code: 2  }, { text: "3", code: 3  },
        { text: "4", code: 4  }, { text: "5", code: 5  }, { text: "6", code: 6  },
        { text: "7", code: 7  }, { text: "8", code: 8  }, { text: "9", code: 9  },
        { text: "删除", type: "del", code: 16 }, { text: "0", code: 0 }, { text: "确定", code: 17 },
      ]

      Column {
        //width: bottomGrid.width / 3
        spacing: dp(5)
        Common.MenuButton {
          text: modelData.text
          width: 50
          height: 50
          onClicked: {
            buttonPressed(modelData.code)
          }
        }
      }
    }
  }
}
